import request from './request'

export function query ({currentPage = 1, perPage = 10, productName, productType, productNo, categoryNo} = {}) {
  return request({
    url: '/console/product/queryAllInfoByMcht.do',
    method: 'POST',
    body: {currentPage, perPage, productName, productType, productNo, categoryNo}
  })
}

export function queryMenuAll () {
  return request({
    url: '/console/product/queryAllInfo.do',
    method: 'POST'
  })
}

export function queryPro (id) {
  return request({
    url: '/console/product/queryInfo.do',
    method: 'POST',
    body: {id}
  })
}

export function create ({productName, originalPrice, categoryNo, productDetails, status, serialNumber, productType, salePrice, freight, sales, payMethod, fileExcel}) {
  return request({
    url: '/console/product/addInfo.do',
    method: 'POST',
    body: {productName, originalPrice, categoryNo, productDetails, status, serialNumber, productType, salePrice, freight, sales, payMethod, fileExcel}
  })
}

export function edit ({productName, id, originalPrice, categoryNo, productDetails, serialNumber, productType, salePrice, freight, sales, payMethod}) {
  return request({
    url: '/console/product/updateInfo.do',
    method: 'POST',
    body: {productName, id, originalPrice, categoryNo, productDetails, serialNumber, productType, salePrice, freight, sales, payMethod}
  })
}

export function del (id) {
  return request({
    url: '/console/product/deleteInfo.do',
    method: 'POST',
    body: {id}
  })
}

export function sold (id) {
  return request({
    url: '/console/product/soldProduct.do',
    method: 'POST',
    body: {id}
  })
}

export function soldOut (id) {
  return request({
    url: '/console/product/soldOutProduct.do',
    method: 'POST',
    body: {id}
  })
}

export function queryCategory () {
  return request({
    url: '/console/product/queryAllCategory.do',
    method: 'POST'
  })
}

export function queryBanner (productNo) {
  return request({
    url: '/console/product/queryAllBanner.do',
    method: 'POST',
    body: {productNo}
  })
}

export function addBanner ({productNo, serialNumber, bannerImg}={}) {
  return request({
    url: '/console/product/addBanner.do',
    method: 'POST',
    body: {productNo, serialNumber, bannerImg}
  })
}

export function updateBanner ({productNo, id, serialNumber, bannerImg}={}) {
  return request({
    url: '/console/product/updateBanner.do',
    method: 'POST',
    body: {productNo, id, serialNumber, bannerImg}
  })
}


export function deleteBanner ({productNo, id}={}) {
  return request({
    url: '/console/product/deleteBanner.do',
    method: 'POST',
    body: {productNo, id}
  })
}

export function queryAllCategory () {
  return request({
    url: '/console/product/queryAllCategory.do',
    method: 'POST'
  })
}